<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>修改页面</title>
		<link rel="stylesheet" href="/static/component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="">
      <div class="mainBox">
				<div class="main-container">
            <div class="layui-form-item layui-hide">
            <input type="text" name="id" class="layui-input" value="{$vip.id}">
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">Vip级别</label>
              <div class="layui-input-inline" >
              <select name="vip">
              {volist name="level" id="vo"}
                <option {if condition="$vip.vip eq $vo"} selected {/if} value="{$vo}">{if condition="$vo eq 0"}普通{else /}VIP{$vo}{/if}</option>
              {/volist}
              </select>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">积分区间</label>
              <div class="layui-input-inline">
                <input type="text" name="score" lay-verify="required" placeholder="积分区间:0-99" autocomplete="off" class="layui-input" value="{$vip.score}">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">认证</label>
              <div class="layui-input-inline">
                <input type="text" name="nick" lay-verify="required" placeholder="等级昵称" autocomplete="off" class="layui-input" value="{$vip.nick}">
              </div>
            </div>	
            <div class="layui-form-item">
              <label class="layui-form-label">权限</label>
              <div class="layui-input-inline">
                <input type="text" name="rules" lay-verify="" placeholder="请选择" autocomplete="off" class="layui-input" value="{$vip.rules}">
              </div>
            </div>
          </div>
        </div>

        <div class="bottom">
          <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
              lay-filter="user-save">
              <i class="layui-icon layui-icon-ok"></i>
              提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
              <i class="layui-icon layui-icon-refresh"></i>
              重置
            </button>
          </div>
        </div>
      </form>
      <script src="/static/component/layui/layui.js"></script>
      <script src="/static/component/pear/pear.js"></script>
      <script>
        layui.use(['form', 'jquery'], function() {
          let form = layui.form;
          let $ = layui.jquery;

          form.on('submit(user-save)', function(data) {
            $.ajax({
              url: "{:url('user.vip/edit')}",
              data: JSON.stringify(data.field),
              dataType: 'json',
              contentType: 'application/json',
              type: 'post',
              success: function(result) {
                if (result.code === 0) {
                  layer.msg(result.msg, {
                    icon: 1,
                    time: 1000
                  }, function() {
                    parent.layer.close(parent.layer.getFrameIndex(window
                      .name)); //关闭当前页
                    parent.layui.table.reload("vip-table");
                  });
                } else {
                  layer.msg(result.msg, {
                    icon: 2,
                    time: 1000
                  });
                }
              }
            })
            return false;
          });
        })
      </script>
  </body>
</html>
